package de.revdev.llt.module.filecardboxes;

import de.revdev.llt.module.classroom.PrivateClassRoom;
import de.revdev.llt.module.classroom.PublicClassRoom;
import de.revdev.llt.module.interfaces.EntityInterface;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author f.lindermaier
 */
@Entity
@Table(name = "tbl_filecardbox")
public class FileCardBox implements Serializable, EntityInterface {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String title;
    private String description;
    @OneToOne
    private Category category;
    @ManyToMany(mappedBy = "fileCardBoxes", targetEntity = PublicClassRoom.class)
    private List<PublicClassRoom> publicClassRooms;
    @ManyToMany(mappedBy = "fileCardBoxes")
    private List<PrivateClassRoom> privateClassRooms;
    @OneToMany(mappedBy = "fileCardBox", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<FileCard> fileCards;

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public List<PublicClassRoom> getPublicClassRooms() {
        return publicClassRooms;
    }

    public void setPublicClassRooms(List<PublicClassRoom> publicClassRooms) {
        this.publicClassRooms = publicClassRooms;
    }

    public List<PrivateClassRoom> getPrivateClassRooms() {
        return privateClassRooms;
    }

    public void setPrivateClassRooms(List<PrivateClassRoom> privateClassRooms) {
        this.privateClassRooms = privateClassRooms;
    }

    public List<FileCard> getFileCards() {
        return fileCards;
    }

    public void setFileCards(List<FileCard> fileCards) {
        this.fileCards = fileCards;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FileCardBox)) {
            return false;
        }
        FileCardBox other = (FileCardBox) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "de.revdev.llt.bean.entities.FileCardBox[ id=" + id + " ]";
    }
}
